/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: hp
 * Date: 2024-03-21
 * Time: 15:03
 */

class MyArray <T>{
    Object[] array = new Object[10];
    //public T[] array1 = (T[])new Object[10];
    //public T[] array1 = new T[10];
    /*public T[] getArray1() {
        return array1;
    }*/

    public void setArray(int pos,T x) {
        array[pos] = x;
    }

    public T getArray(int pos) {
        return (T)array[pos];
    }
}

class Alg<T extends Comparable<T>> {

    public  T findMax(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            if(array[i].compareTo(max) > 0) {
                max = array[i];
            }
        }
        return max;
    }
}

class Person {

}

class Alg2 {
    public <T extends Comparable<T>> T findMax(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            if(array[i].compareTo(max) > 0) {
                max = array[i];
            }
        }
        return max;
    }
}

class Alg3 {
    public static <T extends Comparable<T>> T findMax(T[] array) {
        T max = array[0];
        for (int i = 0; i < array.length; i++) {
            if(array[i].compareTo(max) > 0) {
                max = array[i];
            }
        }
        return max;
    }
}
public class Test {
    public static void main(String[] args) {
        Alg2 alg2 = new Alg2();
        Integer[] integers = {1,2,3,4,5,6,7};
        Integer x = alg2.<Integer>findMax(integers);
        System.out.println(x);

        Integer[] integers1 = {1,2,3,4,5,6,7};
        Integer x1 = Alg3.<Integer>findMax(integers);
        System.out.println(x);
    }


    public static void main7(String[] args) {
        Alg<Integer> alg = new Alg<>();
        //Alg<Person> alg1 = new Alg<>();
        Integer[] integers = {1,2,3,4,5,6,7};
        Integer x = alg.findMax(integers);
        System.out.println(x);
    }


    public static void main6(String[] args) {
        /*MyArray<String> myArray = new MyArray<>();
        Object[] s = myArray.getArray1();*/

    }



    public static void main5(String[] args) {
        MyArray<Integer> myArray = new MyArray<Integer>();
        myArray.setArray(0,1);
        myArray.setArray(1,12);
        //myArray.setArray(2,"hello");

        Integer x = myArray.getArray(0);
        System.out.println(x);
    }


    public static void main4(String[] args) {
        MyArray myArray = new MyArray();
        myArray.setArray(0,1);
        myArray.setArray(1,12);
        myArray.setArray(2,"hello");

        String s = (String)myArray.getArray(2);
        System.out.println(s);
    }

    /*public static void main3(String[] args) {
        Integer a1 = 100;
        Integer a2 = 100;
        System.out.println(a1==a2);

        Integer a3 = 200;
        Integer a4 = 200;
        System.out.println(a3==a4);
    }*/

    /*public static void main2(String[] args) {
        Integer aa = 10;//装箱

        int a = aa;//自动拆箱

        int a1 = aa.intValue();//手动拆箱

        double a2 = aa.doubleValue();
    }*/

    /*public static void main1(String[] args) {
        int a = 10;
        Integer ia = Integer.valueOf(a);
        Integer iaa = a;

        //方法过时
        //Integer i = new Integer(a)
    }*/

    /*long factorial(int N) {
        return N < 2 ? N : factorial(N-1)*N;
    }*/


    /*int[] fibonacci(int n) {
        long[] fibArray = new long[n + 1];
        fibArray[0] = 0;
        fibArray[1] = 1;
        for (int i = 2; i <= n ; i++) {
            fibArray[i] = fibArray[i - 1] + fibArray [i - 2];
        }
        return fibArray;
    }*/

    /*void bubbleSort(int[] array) {
        for (int end = array.length; end > 0; end--) {
            boolean sorted = true;
            for (int i = 1; i < end; i++) {
                if (array[i - 1] > array[i]) {
                    Swap(array, i - 1, i);
                    sorted = false;
                }
            } if
            (sorted == true) {
                break;
            }
        }
    }*/



}
